﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HRP.Private.Funcionarios.Controlos
{
    public partial class Criar_Resumo : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            submitButton.Click += submitButton_Click;
        }

        void submitButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
                return;

            Criar_Dados cd = (Criar_Dados)this.Parent.FindControl("criarDadosUC");
            int funcionarioId = cd.Gravar();
            if (funcionarioId != -1)
            {
                Criar_Contrato cc = (Criar_Contrato)this.Parent.FindControl("criarContratoUC");
                cc.Gravar(funcionarioId);
                this.Parent.FindControl("wizardForm").Visible = false;
                this.Parent.FindControl("msgPanel").Visible = true;
                this.Parent.FindControl("errorPanel").Visible = false;
            }
            else
            {
                this.Parent.FindControl("wizardForm").Visible = false;
                this.Parent.FindControl("msgPanel").Visible = false;
                this.Parent.FindControl("errorPanel").Visible = true;
            }

        }
    }
}